In one type of computer graphics imaging known as bit-mapped graphics, the color of each pixel of an image is controlled by a group of one or more data bits stored in a memory or frame buffer. Generally, the data bits are stored in a sequential order in the memory such as in a series or string of bytes. Commonly, a byte contains eight bits, but not necessarily, and in the specification the term is to be understood as including a group of bits of any convenient length. (Generally, the smallest addressable unit of the memory is a byte.) The group of bits controlling the color of the pixel in the top left corner of the image is usually placed first in the memory. Following is the group of bits that control the pixel to the right of the first pixel. This sequential organization of the data bits in the memory proceeds from left to right along the top line of pixels, then from left to right along each line from the top to the bottom of the image.
The sequential organization of the data in the memory can be advantageous to computer manipulation of the graphics image. For example, since consecutive groups of data bits in the memory map to consecutive pixels in horizontal lines of the image, horizontal line segments can be drawn quickly and easily by the computer. The computer simply stores a bit pattern corresponding to a desired line color to consecutive storage locations in the memory that map to pixels within the line segment.
The ability to draw horizontal line segments quickly is important in many graphics operations. One common graphics operation that uses horizontal line segment drawing is that of "filling" a closed figure in an image with a solid color. The "fill" is accomplished by drawing a number of short horizontal line segments extending between the left to right edges of the closed figure. A number of such lines, one drawn below another from top to bottom of the figure, fill the figure with a single solid color.
The ability of computers to quickly draw solid color, horizontal line segments, however, can be affected by the number of data bits controlling the color of pixels in the image. This is because computer systems are generally structured to most efficiently transfer, or store, only certain numbers of data bits at a time. For example, a computer with a 32-bit central processing unit (processor) reads and writes data with its processor to memory most efficiently in groups of 32-bits (double words). Further, some 32-bit processors store double words most efficiently to memory locations aligned with every fourth byte of memory (double word boundaries). Such 32-bit processors are therefore best suited to repeatedly store a 32-bit long pattern to consecutive locations aligned with double word boundaries in a memory. The 32-bit processor simply loads the 32-bit pattern from memory into an internal register, then repeatedly stores the pattern in consecutive 32-bit double words to the memory in double word boundary alignment.
This straightforward procedure can be used effectively for drawing line segments when pixels map to groups of 32-bits and even to groups of 16 or 8-bits. (When 16 and 8-bit groups map to a pixel, the line can be drawn 2 and 4 pixels at a time respectively by consecutively storing a 32-bit pattern to the memory.) Exemplary assembly language code listings for an Intel 80386 or 80486 microprocessor implementing this procedure for 8, 16, and 32-bit per pixel (bpp) images are illustrated in the following tables 1-3.
TABLE 1 ______________________________________ Code for drawing 1000 pixel, 32-bpp line. mov eax,&lt;32-bit color&gt; mov ecx, 1000 rep stosd ______________________________________
TABLE 2 ______________________________________ Code for drawing 2000 pixel, 16-bpp line. mov eax, &lt;16-bit color, 16-bit color&gt; mov ecx, 1000 rep stosd ______________________________________
TABLE 3 ______________________________________ Code for drawing 4000 pixel, 8-bpp line. mov eax, &lt;8-bit color repeated 4.times.&gt; mov ecx, 1000 rep stosd ______________________________________
However, the procedure is not effective for bit-mapped images that use 24-bits per pixel. With 24-bit per pixel images, the required pattern does not repeat once every 32-bits. Instead, the pattern repeats 11/3 times every 32-bits and therefore cannot be created by consecutively storing a single 32-bit pattern.
A technique for effectively storing a sequence containing a repeated 24-bit pattern to memory in consecutive 32-bit double word increments is therefore needed.